<template>
<div id="">
<ul>
	<li v-for="(songs,index) in cdlist.songlist">
		{{songs.songname}}
		<button @click="play(songs.songid)">播放</button>
		<button @click="next()">下一首</button>
		<button @click="prev()">上一首</button>
		
	</li>
</ul>
</div>
</template>

<script>
	//var albmMid = "001wUwND10osKJ";
	//var albmPic = "https://y.gtimg.cn/music/photo_new/T002R300x300M000"+ albmMid +".jpg?max_age=2592000;
	
	import api from "../js/api.js";
	export default{
		data:function(){
			return {
				
				cdlist:[]
			}
		},
		created:function(){
			var id = this.$route.query.id
			console.log(id)
			//请求数据
			api.getSongList(id).then((res)=>{
				console.log(res)
				this.cdlist=res.data.cdlist[0];
				//把歌曲id存在数组内
				this.songIdList=res.data.cdlist[0].songlist.map(function(item,index){
					return item.songmid;
				})
				console.log(this.songIdList)
			});
			this.player=new QMplayer();	
		},
		methods:{
			play:function(num) {
				//play(歌曲id，（字符串，数组，下标)
				this.player.play(this,songIdList,{index:id});
			},
			next:function() {
				//下一首
				this.player.playerNext();
			},
			prev:function() {
				//上一首
				this.player.playerprev();
			}
		}
	}
</script>

<style>
</style>